<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.13.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>CAD_Doc: Legacy gMock FAQ</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
  $(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">CAD_Doc<span id="projectnumber">&#160;1.0</span>
   </div>
   <div id="projectbrief">cad synopsis</div>
  </td>
    <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <span id="MSearchSelect"                onmouseover="return searchBox.OnSearchSelectShow()"                onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
          <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.13.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('md__build_2__deps_2googletest-src_2docs_2gmock__faq.html',''); initResizable(true); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title">Legacy gMock FAQ</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="autotoc_md180"></a></p>
<h2><a class="anchor" id="autotoc_md181"></a>
When I call a method on my mock object, the method for the real object is invoked instead. What's the problem?</h2>
<p>In order for a method to be mocked, it must be <em>virtual</em>, unless you use the <a href="gmock_cook_book.md#MockingNonVirtualMethods">high-perf dependency injection technique</a>.</p>
<h2><a class="anchor" id="autotoc_md182"></a>
Can I mock a variadic function?</h2>
<p>You cannot mock a variadic function (i.e. a function taking ellipsis (<code>...</code>) arguments) directly in gMock.</p>
<p>The problem is that in general, there is <em>no way</em> for a mock object to know how many arguments are passed to the variadic method, and what the arguments' types are. Only the <em>author of the base class</em> knows the protocol, and we cannot look into his or her head.</p>
<p>Therefore, to mock such a function, the <em>user</em> must teach the mock object how to figure out the number of arguments and their types. One way to do it is to provide overloaded versions of the function.</p>
<p>Ellipsis arguments are inherited from C and not really a C++ feature. They are unsafe to use and don't work with arguments that have constructors or destructors. Therefore we recommend to avoid them in C++ as much as possible.</p>
<h2><a class="anchor" id="autotoc_md183"></a>
MSVC gives me warning C4301 or C4373 when I define a mock method with a const parameter. Why?</h2>
<p>If you compile this using Microsoft Visual C++ 2005 SP1:</p>
<div class="fragment"><div class="line"><span class="keyword">class </span>Foo {</div>
<div class="line">  ...</div>
<div class="line">  <span class="keyword">virtual</span> <span class="keywordtype">void</span> Bar(<span class="keyword">const</span> <span class="keywordtype">int</span> i) = 0;</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keyword">class </span>MockFoo : <span class="keyword">public</span> Foo {</div>
<div class="line">  ...</div>
<div class="line">  MOCK_METHOD(<span class="keywordtype">void</span>, Bar, (<span class="keyword">const</span> <span class="keywordtype">int</span> i), (<span class="keyword">override</span>));</div>
<div class="line">};</div>
</div><!-- fragment --><p>You may get the following warning:</p>
<div class="fragment"><div class="line">warning C4301: &#39;MockFoo::Bar&#39;: overriding virtual function only differs from &#39;Foo::Bar&#39; by const/volatile qualifier</div>
</div><!-- fragment --><p>This is a MSVC bug. The same code compiles fine with gcc, for example. If you use Visual C++ 2008 SP1, you would get the warning:</p>
<div class="fragment"><div class="line">warning C4373: &#39;MockFoo::Bar&#39;: virtual function overrides &#39;Foo::Bar&#39;, previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers</div>
</div><!-- fragment --><p>In C++, if you <em>declare</em> a function with a <code>const</code> parameter, the <code>const</code> modifier is ignored. Therefore, the <code>Foo</code> base class above is equivalent to:</p>
<div class="fragment"><div class="line"><span class="keyword">class </span>Foo {</div>
<div class="line">  ...</div>
<div class="line">  <span class="keyword">virtual</span> <span class="keywordtype">void</span> Bar(<span class="keywordtype">int</span> i) = 0;  <span class="comment">// int or const int?  Makes no difference.</span></div>
<div class="line">};</div>
</div><!-- fragment --><p>In fact, you can <em>declare</em> <code>Bar()</code> with an <code>int</code> parameter, and define it with a <code>const int</code> parameter. The compiler will still match them up.</p>
<p>Since making a parameter <code>const</code> is meaningless in the method declaration, we recommend to remove it in both <code>Foo</code> and <code><a class="el" href="class_mock_foo.html">MockFoo</a></code>. That should workaround the VC bug.</p>
<p>Note that we are talking about the <em>top-level</em> <code>const</code> modifier here. If the function parameter is passed by pointer or reference, declaring the pointee or referee as <code>const</code> is still meaningful. For example, the following two declarations are <em>not</em> equivalent:</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> Bar(<span class="keywordtype">int</span>* p);         <span class="comment">// Neither p nor *p is const.</span></div>
<div class="line"><span class="keywordtype">void</span> Bar(<span class="keyword">const</span> <span class="keywordtype">int</span>* p);  <span class="comment">// p is not const, but *p is.</span></div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md184"></a>
I can't figure out why gMock thinks my expectations are not satisfied. What should I do?</h2>
<p>You might want to run your test with <code>--gmock_verbose=info</code>. This flag lets gMock print a trace of every mock function call it receives. By studying the trace, you'll gain insights on why the expectations you set are not met.</p>
<p>If you see the message "The mock function has no default action set, and its
return type has no default value set.", then try <a href="gmock_cheat_sheet.md#OnCall">adding a default action</a>. Due to a known issue, unexpected calls on mocks without default actions don't print out a detailed comparison between the actual arguments and the expected arguments.</p>
<h2><a class="anchor" id="autotoc_md185"></a>
My program crashed and <code>ScopedMockLog</code> spit out tons of messages. Is it a gMock bug?</h2>
<p>gMock and <code>ScopedMockLog</code> are likely doing the right thing here.</p>
<p>When a test crashes, the failure signal handler will try to log a lot of information (the stack trace, and the address map, for example). The messages are compounded if you have many threads with depth stacks. When <code>ScopedMockLog</code> intercepts these messages and finds that they don't match any expectations, it prints an error for each of them.</p>
<p>You can learn to ignore the errors, or you can rewrite your expectations to make your test more robust, for example, by adding something like:</p>
<div class="fragment"><div class="line"><span class="keyword">using </span>::testing::AnyNumber;</div>
<div class="line"><span class="keyword">using </span>::testing::Not;</div>
<div class="line">...</div>
<div class="line">  <span class="comment">// Ignores any log not done by us.</span></div>
<div class="line">  EXPECT_CALL(log, Log(_, Not(EndsWith(<span class="stringliteral">&quot;/my_file.cc&quot;</span>)), _))</div>
<div class="line">      .Times(AnyNumber());</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md186"></a>
How can I assert that a function is NEVER called?</h2>
<div class="fragment"><div class="line"><span class="keyword">using </span>::testing::_;</div>
<div class="line">...</div>
<div class="line">  EXPECT_CALL(foo, Bar(_))</div>
<div class="line">      .Times(0);</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md187"></a>
I have a failed test where gMock tells me TWICE that a particular expectation is not satisfied. Isn't this redundant?</h2>
<p>When gMock detects a failure, it prints relevant information (the mock function arguments, the state of relevant expectations, and etc) to help the user debug. If another failure is detected, gMock will do the same, including printing the state of relevant expectations.</p>
<p>Sometimes an expectation's state didn't change between two failures, and you'll see the same description of the state twice. They are however <em>not</em> redundant, as they refer to <em>different points in time</em>. The fact they are the same <em>is</em> interesting information.</p>
<h2><a class="anchor" id="autotoc_md188"></a>
I get a heapcheck failure when using a mock object, but using a real object is fine. What can be wrong?</h2>
<p>Does the class (hopefully a pure interface) you are mocking have a virtual destructor?</p>
<p>Whenever you derive from a base class, make sure its destructor is virtual. Otherwise Bad Things will happen. Consider the following code:</p>
<div class="fragment"><div class="line"><span class="keyword">class </span><a class="code hl_class" href="class_base.html">Base</a> {</div>
<div class="line"> <span class="keyword">public</span>:</div>
<div class="line">  <span class="comment">// Not virtual, but should be.</span></div>
<div class="line">  <a class="code hl_class" href="class_base.html">~Base</a>() { ... }</div>
<div class="line">  ...</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keyword">class </span>Derived : <span class="keyword">public</span> <a class="code hl_class" href="class_base.html">Base</a> {</div>
<div class="line"> <span class="keyword">public</span>:</div>
<div class="line">  ...</div>
<div class="line"> <span class="keyword">private</span>:</div>
<div class="line">  std::string value_;</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line">  <a class="code hl_class" href="class_base.html">Base</a>* p = <span class="keyword">new</span> Derived;</div>
<div class="line">  ...</div>
<div class="line">  <span class="keyword">delete</span> p;  <span class="comment">// Surprise! ~Base() will be called, but ~Derived() will not</span></div>
<div class="line">                 <span class="comment">// - value_ is leaked.</span></div>
<div class="ttc" id="aclass_base_html"><div class="ttname"><a href="class_base.html">Base</a></div><div class="ttdef"><b>Definition</b> gtest_unittest.cc:5101</div></div>
</div><!-- fragment --><p>By changing <code>~Base()</code> to virtual, <code>~Derived()</code> will be correctly called when <code>delete p</code> is executed, and the heap checker will be happy.</p>
<h2><a class="anchor" id="autotoc_md189"></a>
The "newer expectations override older ones" rule makes writing expectations awkward. Why does gMock do that?</h2>
<p>When people complain about this, often they are referring to code like:</p>
<div class="fragment"><div class="line"><span class="keyword">using </span>::testing::Return;</div>
<div class="line">...</div>
<div class="line">  <span class="comment">// foo.Bar() should be called twice, return 1 the first time, and return</span></div>
<div class="line">  <span class="comment">// 2 the second time.  However, I have to write the expectations in the</span></div>
<div class="line">  <span class="comment">// reverse order.  This sucks big time!!!</span></div>
<div class="line">  EXPECT_CALL(foo, Bar())</div>
<div class="line">      .WillOnce(Return(2))</div>
<div class="line">      .RetiresOnSaturation();</div>
<div class="line">  EXPECT_CALL(foo, Bar())</div>
<div class="line">      .WillOnce(Return(1))</div>
<div class="line">      .RetiresOnSaturation();</div>
</div><!-- fragment --><p>The problem, is that they didn't pick the <b>best</b> way to express the test's intent.</p>
<p>By default, expectations don't have to be matched in <em>any</em> particular order. If you want them to match in a certain order, you need to be explicit. This is gMock's (and jMock's) fundamental philosophy: it's easy to accidentally over-specify your tests, and we want to make it harder to do so.</p>
<p>There are two better ways to write the test spec. You could either put the expectations in sequence:</p>
<div class="fragment"><div class="line"><span class="keyword">using </span>::testing::Return;</div>
<div class="line">...</div>
<div class="line">  <span class="comment">// foo.Bar() should be called twice, return 1 the first time, and return</span></div>
<div class="line">  <span class="comment">// 2 the second time.  Using a sequence, we can write the expectations</span></div>
<div class="line">  <span class="comment">// in their natural order.</span></div>
<div class="line">  {</div>
<div class="line">    InSequence s;</div>
<div class="line">    EXPECT_CALL(foo, Bar())</div>
<div class="line">        .WillOnce(Return(1))</div>
<div class="line">        .RetiresOnSaturation();</div>
<div class="line">    EXPECT_CALL(foo, Bar())</div>
<div class="line">        .WillOnce(Return(2))</div>
<div class="line">        .RetiresOnSaturation();</div>
<div class="line">  }</div>
</div><!-- fragment --><p>or you can put the sequence of actions in the same expectation:</p>
<div class="fragment"><div class="line"><span class="keyword">using </span>::testing::Return;</div>
<div class="line">...</div>
<div class="line">  <span class="comment">// foo.Bar() should be called twice, return 1 the first time, and return</span></div>
<div class="line">  <span class="comment">// 2 the second time.</span></div>
<div class="line">  EXPECT_CALL(foo, Bar())</div>
<div class="line">      .WillOnce(Return(1))</div>
<div class="line">      .WillOnce(Return(2))</div>
<div class="line">      .RetiresOnSaturation();</div>
</div><!-- fragment --><p>Back to the original questions: why does gMock search the expectations (and <code>ON_CALL</code>s) from back to front? Because this allows a user to set up a mock's behavior for the common case early (e.g. in the mock's constructor or the test fixture's set-up phase) and customize it with more specific rules later. If gMock searches from front to back, this very useful pattern won't be possible.</p>
<h2><a class="anchor" id="autotoc_md190"></a>
gMock prints a warning when a function without EXPECT_CALL is called, even if I have set its behavior using ON_CALL. Would it be reasonable not to show the warning in this case?</h2>
<p>When choosing between being neat and being safe, we lean toward the latter. So the answer is that we think it's better to show the warning.</p>
<p>Often people write <code>ON_CALL</code>s in the mock object's constructor or <code>SetUp()</code>, as the default behavior rarely changes from test to test. Then in the test body they set the expectations, which are often different for each test. Having an <code>ON_CALL</code> in the set-up part of a test doesn't mean that the calls are expected. If there's no <code>EXPECT_CALL</code> and the method is called, it's possibly an error. If we quietly let the call go through without notifying the user, bugs may creep in unnoticed.</p>
<p>If, however, you are sure that the calls are OK, you can write</p>
<div class="fragment"><div class="line"><span class="keyword">using </span>::testing::_;</div>
<div class="line">...</div>
<div class="line">  EXPECT_CALL(foo, Bar(_))</div>
<div class="line">      .WillRepeatedly(...);</div>
</div><!-- fragment --><p>instead of</p>
<div class="fragment"><div class="line"><span class="keyword">using </span>::testing::_;</div>
<div class="line">...</div>
<div class="line">  ON_CALL(foo, Bar(_))</div>
<div class="line">      .WillByDefault(...);</div>
</div><!-- fragment --><p>This tells gMock that you do expect the calls and no warning should be printed.</p>
<p>Also, you can control the verbosity by specifying <code>--gmock_verbose=error</code>. Other values are <code>info</code> and <code>warning</code>. If you find the output too noisy when debugging, just choose a less verbose level.</p>
<h2><a class="anchor" id="autotoc_md191"></a>
How can I delete the mock function's argument in an action?</h2>
<p>If your mock function takes a pointer argument and you want to delete that argument, you can use testing::DeleteArg&lt;N&gt;() to delete the N'th (zero-indexed) argument:</p>
<div class="fragment"><div class="line"><span class="keyword">using </span>::testing::_;</div>
<div class="line">  ...</div>
<div class="line">  MOCK_METHOD(<span class="keywordtype">void</span>, Bar, (X* x, <span class="keyword">const</span> Y&amp; y));</div>
<div class="line">  ...</div>
<div class="line">  EXPECT_CALL(mock_foo_, Bar(_, _))</div>
<div class="line">      .WillOnce(testing::DeleteArg&lt;0&gt;()));</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md192"></a>
How can I perform an arbitrary action on a mock function's argument?</h2>
<p>If you find yourself needing to perform some action that's not supported by gMock directly, remember that you can define your own actions using <a class="el" href="md__build_2__deps_2googletest-src_2docs_2gmock__cook__book.html#NewMonoActions">`MakeAction()`</a> or <a class="el" href="md__build_2__deps_2googletest-src_2docs_2gmock__cook__book.html#NewPolyActions">`MakePolymorphicAction()`</a>, or you can write a stub function and invoke it using <a class="el" href="md__build_2__deps_2googletest-src_2docs_2gmock__cook__book.html#FunctionsAsActions">`Invoke()`</a>.</p>
<div class="fragment"><div class="line"><span class="keyword">using </span>::testing::_;</div>
<div class="line"><span class="keyword">using </span>::testing::Invoke;</div>
<div class="line">  ...</div>
<div class="line">  MOCK_METHOD(<span class="keywordtype">void</span>, Bar, (X* p));</div>
<div class="line">  ...</div>
<div class="line">  EXPECT_CALL(mock_foo_, Bar(_))</div>
<div class="line">      .WillOnce(Invoke(MyAction(...)));</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md193"></a>
My code calls a static/global function. Can I mock it?</h2>
<p>You can, but you need to make some changes.</p>
<p>In general, if you find yourself needing to mock a static function, it's a sign that your modules are too tightly coupled (and less flexible, less reusable, less testable, etc). You are probably better off defining a small interface and call the function through that interface, which then can be easily mocked. It's a bit of work initially, but usually pays for itself quickly.</p>
<p>This Google Testing Blog <a href="https://testing.googleblog.com/2008/06/defeat-static-cling.html">post</a> says it excellently. Check it out.</p>
<h2><a class="anchor" id="autotoc_md194"></a>
My mock object needs to do complex stuff. It's a lot of pain to specify the actions. gMock sucks!</h2>
<p>I know it's not a question, but you get an answer for free any way. :-)</p>
<p>With gMock, you can create mocks in C++ easily. And people might be tempted to use them everywhere. Sometimes they work great, and sometimes you may find them, well, a pain to use. So, what's wrong in the latter case?</p>
<p>When you write a test without using mocks, you exercise the code and assert that it returns the correct value or that the system is in an expected state. This is sometimes called "state-based testing".</p>
<p>Mocks are great for what some call "interaction-based" testing: instead of checking the system state at the very end, mock objects verify that they are invoked the right way and report an error as soon as it arises, giving you a handle on the precise context in which the error was triggered. This is often more effective and economical to do than state-based testing.</p>
<p>If you are doing state-based testing and using a test double just to simulate the real object, you are probably better off using a fake. Using a mock in this case causes pain, as it's not a strong point for mocks to perform complex actions. If you experience this and think that mocks suck, you are just not using the right tool for your problem. Or, you might be trying to solve the wrong problem. :-)</p>
<h2><a class="anchor" id="autotoc_md195"></a>
I got a warning "Uninteresting function call encountered - default action taken.." Should I panic?</h2>
<p>By all means, NO! It's just an FYI. :-)</p>
<p>What it means is that you have a mock function, you haven't set any expectations on it (by gMock's rule this means that you are not interested in calls to this function and therefore it can be called any number of times), and it is called. That's OK - you didn't say it's not OK to call the function!</p>
<p>What if you actually meant to disallow this function to be called, but forgot to write <code>EXPECT_CALL(foo, Bar()).Times(0)</code>? While one can argue that it's the user's fault, gMock tries to be nice and prints you a note.</p>
<p>So, when you see the message and believe that there shouldn't be any uninteresting calls, you should investigate what's going on. To make your life easier, gMock dumps the stack trace when an uninteresting call is encountered. From that you can figure out which mock function it is, and how it is called.</p>
<h2><a class="anchor" id="autotoc_md196"></a>
I want to define a custom action. Should I use Invoke() or implement the ActionInterface interface?</h2>
<p>Either way is fine - you want to choose the one that's more convenient for your circumstance.</p>
<p>Usually, if your action is for a particular function type, defining it using <code>Invoke()</code> should be easier; if your action can be used in functions of different types (e.g. if you are defining <code>Return(*value*)</code>), <code>MakePolymorphicAction()</code> is easiest. Sometimes you want precise control on what types of functions the action can be used in, and implementing <code>ActionInterface</code> is the way to go here. See the implementation of <code>Return()</code> in <code><a class="el" href="gmock-actions_8h_source.html">gmock-actions.h</a></code> for an example.</p>
<h2><a class="anchor" id="autotoc_md197"></a>
I use SetArgPointee() in WillOnce(), but gcc complains about "conflicting return type specified". What does it mean?</h2>
<p>You got this error as gMock has no idea what value it should return when the mock method is called. <code>SetArgPointee()</code> says what the side effect is, but doesn't say what the return value should be. You need <code>DoAll()</code> to chain a <code>SetArgPointee()</code> with a <code>Return()</code> that provides a value appropriate to the API being mocked.</p>
<p>See this <a href="gmock_cook_book.md#mocking-side-effects">recipe</a> for more details and an example.</p>
<h2><a class="anchor" id="autotoc_md198"></a>
I have a huge mock class, and Microsoft Visual C++ runs out of memory when compiling it. What can I do?</h2>
<p>We've noticed that when the <code>/clr</code> compiler flag is used, Visual C++ uses 5~6 times as much memory when compiling a mock class. We suggest to avoid <code>/clr</code> when compiling native C++ mocks. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.13.2 </li>
  </ul>
</div>
</body>
</html>
